/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sudoku;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.ComponentOrientation;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.MenuBar;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Taras
 */
public class SudokuFrame extends JFrame{

    //private final int DEF_X = 650;
    //private final int DEF_Y = 500;

    private double zoom = 1;

    public SudokuFrame(double z){

        super("Sudoku Game");

        zoom = z;

        //setSize(x,y);
        setResizable(false);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLayout(new BorderLayout());
        
       // menuSet();

        ClassicSudokuCanvas canvas = new ClassicSudokuCanvas(this, new ClassicGrid());
        add(canvas, BorderLayout.WEST);

        sidePanel();

        pack();
        setVisible(true);
    }

    private void menuSet(){
        // menu = new MenuBar();
    }

    private void sidePanel(){

        JPanel sideP = new JPanel();
        sideP.setLayout(new GridLayout(0,1));
        sideP.add(new JLabel("Zoom:"));
        
        JButton plusButt = new JButton("+");
        if (zoom == 1.4) plusButt.setEnabled(false);
        JButton minusButt = new JButton("-");
        if (zoom == 0.6) minusButt.setEnabled(false);

        plusButt.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                switch((int)(zoom*5)){
                    case 3: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(0.8);
                        break;
                    }
                    case 4: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(1);
                        break;
                    }
                    case 5: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(1.2);
                        break;
                    }
                    case 6: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(1.4);
                        break;
                    }
                }
            }
        });

        minusButt.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

                switch((int)(zoom*5)){
                    case 4: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(0.6);
                        break;
                    }
                    case 5: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(0.8);
                        break;
                    }
                    case 6: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(1);
                        break;
                    }
                    case 7: {
                        setVisible(false);
                        SudokuFrame frame = new SudokuFrame(1.2);
                        break;
                    }
                }
            }
        });

        JPanel buttPanel = new JPanel();
        buttPanel.setLayout(new FlowLayout());
        buttPanel.add(plusButt);
        buttPanel.add(minusButt);
        sideP.add(buttPanel);

        add(sideP, BorderLayout.EAST);
    }

}
